﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Expo.Training.DataAccess.Course;
using Expo.Training.Entity;
using System.Net;
using System.Text;
using System.Web.Script.Serialization;
using Expo.Training.DataAccess.Special;

public partial class BM_Special_SpecialDetails : Pagebase
{
    public Guid SpecialID
    {
        get
        {
            if (ViewState["SpecialID"] != null)
            {
                return new Guid(ViewState["SpecialID"].ToString());
            }
            else
            {
                return Guid.Empty;
            }
        }
        set
        {
            ViewState["SpecialID"] = value;
        }
    }

    #region 专项推送元素
    public string SpecialTital = "";
    public string SpecialContent = "";
    public string SpecialDate = "";
    public string SpecialImageUrl = "Default.gif";
    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        SpecialID = GetGuidValue("ID");
        if (!IsPostBack)
        {
            this.PageInit();
        }


    }
    /// <summary>
    /// 初始化页面
    /// </summary>
    public void PageInit()
    {
        //ID错误跳转到列表页
        if (SpecialID == Guid.Empty)
        {
            Response.Redirect("Default.aspx");
            return;
        }
        #region 填充页面元素
        Special_Info ObjSI = new Special_Info();
        ObjSI.SpecialID = SpecialID;
        if (ObjSI.Exist())
        {
            SpecialImageUrl = ObjSI.ImageUrl;
            SpecialTital = ObjSI.SpecialTitle;
            SpecialContent = ObjSI.SpecialContent;
            SpecialDate = ObjSI.AddTime.ToString("yyyy-MM-dd");
        }
        ObjSI.Dispose();        
        #endregion

        //初始化课程列表
        InitCourseList();


    }

    /// <summary>
    /// 初始化课程列表
    /// </summary>
    public void InitCourseList()
    {
       DataTable dt = SpecialManager.GetSpecialCourseListForBM(SpecialID.ToString(),"AddTime Desc");
       rpt_CourseList.DataSource = dt;
       rpt_CourseList.DataBind();
    }


    public string SubString(string str,int Length)
    {
        string StrReturn = str;
        if (str.Length > Length)
        {
            StrReturn = str.Substring(0, Length)+"...";
        }
        return StrReturn;
    }
}
